package com.meaningful.thinking.thread_pool_demo;

import java.util.concurrent.BlockingQueue;

public class DiscardRejectHandle implements RejectHandle{

    @Override
    public void rejected(Runnable rejectCommand, MyThreadPool context) {
        BlockingQueue<Runnable> commandList = context.getCommandList();
        // 丢弃顶部的任务
        Runnable headTask = commandList.poll();
        // 执行未落的队列的任务重新执行
        // 并发情况下大概率重复执行此策略
        context.execute(rejectCommand);
    }

}
